<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String contextPath = request.getContextPath();
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">  
<meta http-equiv="cache-control" content="no-cache">  
<meta http-equiv="expires" content="0"> 

<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/icon.css">
<script type="text/javascript" src="<%=contextPath %>/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/base.js"></script>
<script>contextPath = "<%=contextPath %>";</script>

<script language="javascript">
$(function() {
		
   initDatePicker("query_startPaymentTime");
   initDatePicker("query_endPaymentTime");
   
	initButton("modify-pd", function() {
		openModifyForm();
	});
	
	initButton("query-pd", function() {
		$("#queryForm").attr("action", "payment_listAction.action");
		$("#queryForm").submit();
	});
	
	initButton("delete-pd", function() {
		$("#queryForm").attr("action", "payment_deletePaymentDetailAction.action");
		
		// 清空query_contractId，不在自动弹出付款窗口
		$("#query_contractId").val("");
		
		deleteRecord('queryForm', 'dataTable', 'intId');
	});
	
	initButton("query-reset", function() {
		$("#query_contractName").val("");
		$("#query_contractCode").val("");
		$("#query_startPaymentTime").datebox('setValue', '');
		$("#query_endPaymentTime").datebox('setValue', '');
	
	});
		
	$('#dataTable').datagrid(
			{
				url: "payment_dataGridAction.action?"+buildCondition(),
				width: '100%',
				height: 'auto',
				striped: true,
				fitColumns: false,
				pagination:true,
				columns:[[
					{field:'intId',checkbox:true},
					{field:'contractCode',title:'合同编号',width:80,
						formatter:function(value,rowData,rowIndex){
							return '<a href="#" onclick="openViewForm(\''+rowData['intId']+'\')">' + value + '</a>';
						}},
					{field:'contractName',title:'合同名称',width:120},
					{field:'paymentName',title:'付款方式',width:150},
					{field:'paymentAmount',title:'付款金额',width:80,
						formatter:function(value){
							return moneyForamt(value);	
						}},
					{field:'invoice',title:'是否提供发票',width:100,
						formatter:function(value,rowData,rowIndex){
							if (value == 1) {
								return '提供';
							} else {
								return '不提供';	
							}							
						}},
					{field:'invoiceAmount',title:'发票金额',width:80,
							formatter:function(value,rowData,rowIndex){
								if (rowData['invoice'] == 1) {
									return moneyForamt(value);
								} else {
									return '--';	
								}							
							}},
					{field:'requestTime',title:'申请日期',width:100,
						formatter:function(value,rec){
							if (value == null || value == '') {
								return '';
							} else {
								return new Date(Date.parse(value.replace(/-/g, "/"))).format("yyyy-MM-dd");	
							}							
						}},
					{field:'paymentTime',title:'付款日期',width:100,
						formatter:function(value,rec){
							if (value == null || value == '') {
								return '';
							} else {
								return new Date(Date.parse(value.replace(/-/g, "/"))).format("yyyy-MM-dd");	
							}							
						}},
					{field:'handleUserName',title:'经手人',width:140},
					{field:'remark',title:'付款备注',width:140}
				]]
			});
});


function buildCondition() {

	return "query_contractName="+
		encodeURIComponent($("#query_contractName").val())+
			"&query_contractCode="+
		encodeURIComponent($("#query_contractCode").val())+
			"&query_startPaymentTime="+
		$("#query_startPaymentTime").datebox('getValue')+
			"&query_endPaymentTime="+
		$("#query_endPaymentTime").datebox('getValue');
}
   
</script>
</head>
<body>

 
<form id="queryForm" action="payment_listAction.action" method="post">

<div id="queryDiv" class="easyui-accordion" border="false" style="width: 400px;">
	<div title="查询" iconCls="icon-search" style="overflow:auto;padding:10px;">
	
	<table>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">合同名称:</label>
				<s:textfield name="query_contractName" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">合同编号:</label>
				<s:textfield name="query_contractCode" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">付款日期:</label>
				<s:textfield name="query_startPaymentTime" theme="simple" />
				~
				<s:textfield name="query_endPaymentTime" theme="simple" />
			</td>
		</tr>
		<tr>
			<td style="vertical-align: top;" colspan="2">
				<a href="javascript:void(0)" id="query-pd" class="easyui-linkbutton" iconCls="icon-search">查询</a>
				<a href="javascript:void(0)" id="query-reset" class="easyui-linkbutton" iconCls="icon-back">重置</a>
			</td>
		</tr>
	</table>
	</div>	
</div>
	
<hr/>

<div style="width: 100%;">
	<table id="dataTable" title='付款明细'></table>
</div>
<div style="margin-top: 5px;">
	<a href="javascript:void(0)" id="modify-pd" class="easyui-linkbutton" iconCls="icon-edit">修改</a>
	<a href="javascript:void(0)" id="delete-pd" class="easyui-linkbutton" iconCls="icon-cancel">删除</a>
</div>
 
 <input type="hidden" name="deleteId" id="deleteId" />
 
<s:include value="paymentDetail_new.jsp"></s:include>

</form>

</body>
</html>